//
//  HBVipCell.m
//  HeartBeat
//
//  Created by karong on 2023/9/15.
//

#import "HBVipCell.h"
#import "UIView+WSDraw.h"
#import "HBGoodsModel.h"

@interface HBVipCell ()
@property (weak, nonatomic) IBOutlet UIView *mainView;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *priceLabel;
@property (weak, nonatomic) IBOutlet UILabel *desLabel;
@property (weak, nonatomic) IBOutlet UIView *tagView;

@end

@implementation HBVipCell
- (void)awakeFromNib {
    [super awakeFromNib];
    [self.tagView setupRoundedCornersWithCutCorners:(UIRectCornerTopLeft|UIRectCornerBottomRight) withRadii:CGSizeMake(5, 5)];
}

- (void)setDataWithObject:(HBGoodsModel *)object select:(BOOL)select {
    self.titleLabel.text = object.title;
    self.priceLabel.text = SF(@"$%.2f", object.price);
    self.desLabel.text = object.vip_price_desc;
    [self setDiscountStatusWithObject:object];
    [self setSelectStatus:select];
}

- (void) setDiscountStatusWithObject:(HBGoodsModel *)object {
    if (KIsNullOrEmpty(object.vip_activity_tag)) {
        self.tagView.hidden = YES;
    }
    else {
        self.tagView.hidden = NO;
    }
}

- (void)setSelectStatus:(BOOL)select {
    UIColor * bgColor = select?[UIColor colorFromHexRGB:@"FFFCE9"]:UIColor.clearColor;
    UIColor * borderColor = select?UIColor.font_yellow_FFCC00:[UIColor colorFromHexRGB:@"cecece"];
    CGFloat borderWidth = select?1.5:0.5;
    self.mainView.backgroundColor = bgColor;
    self.mainView.layer.borderColor = borderColor.CGColor;
    self.mainView.layer.borderWidth = borderWidth;
}
@end
